package com.zhu.bitcom.utils;

import java.io.Serializable

 data class Result<T>(
    var code: Int? = null,
    var msg: String? = null,
    var data: T? = null
) : Serializable {


    companion object {
        @JvmStatic
        fun <T> ok(): Result<T> {
            return Result(200, "成功", null)
        }

        @JvmStatic
        fun <T> ok(data: T): Result<T> {
            return Result(200, "成功", data)
        }

        @JvmStatic
        fun <T> ok(code: Int, msg: String, data: T): Result<T> {
            return Result(code, msg, data)
        }

        @JvmStatic
        fun <T> error(msg: String): Result<T> {
            return Result(-1, msg, null)
        }

        @JvmStatic
        fun <T> error(code: Int, msg: String): Result<T> {
            return Result(code, msg, null)
        }

        @JvmStatic
        fun <T> error(code: Int, msg: String, data: T): Result<T> {
            return Result(code, msg, data)
        }
    }

}


